﻿<div class="form-inline">
    <label class="control-label">收件人：</label>
    <div class="input-group">
        <BootstrapInput placeholder="请输入 ..." Value="@InputValue"></BootstrapInput>
        <div class="input-group-append">
            <Button Icon="fa fa-vcard-o" OnClick="@OnEmailButtonClick"></Button>
        </div>
    </div>
</div>

@code {
    // 源码地址 https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/dev/src/BootstrapBlazor.Shared/Pages/Components/ResultDialogDemo2.razor.cs

    private string? InputValue { get; set; }
    private IEnumerable<string>
    Emails { get; set; } = Array.Empty<string>
        ();

        private async Task OnEmailButtonClick()
        {
        var result = await DialogService.ShowModal<ResultDialogDemo2>
            (new ResultDialogOption()
            {
            Title = "选择收件人",
            BodyContext = 10,
            ButtonYesText = "选择",
            ButtonYesIcon = "fa fa-search",
            ComponentParamters = new KeyValuePair<string, object>
                []
                {
                // 用于初始化已选择的用户邮件
                new(nameof(ResultDialogDemo2.Emails), Emails),
                new(nameof(ResultDialogDemo2.EmailsChanged), EventCallback.Factory.Create<IEnumerable<string>>(this, v => Emails = v))
            }
        });

        if (result == DialogResult.Yes)
        {
            InputValue = string.Join(";", Emails);
        }
    }
}
